package com.zlt.dao.Impl;

import com.zlt.dao.RecruiteMenuDao;
import com.zlt.entity.RecruiteMenu;
import com.zlt.entity.Role;
import com.zlt.util.SqlUtil;

import java.util.ArrayList;
import java.util.List;

public class RecruiteMenuDaoImpl implements RecruiteMenuDao {

    @Override
    public List<RecruiteMenu> seelctMenu( List<Role> roles) {
        String sql="select recruite_menu.* from role_recruite_menu left join recruite_menu on recruite_menu.mid=role_recruite_menu.mid where role_recruite_menu.rid=?";
        List<RecruiteMenu> recruiteMenuList=new ArrayList<>();
        for (Role role : roles) {
            Long rid = role.getRid();
            List<RecruiteMenu> select = SqlUtil.select(RecruiteMenu.class, sql, rid);
            if(select!=null) {
                recruiteMenuList.addAll(select);
            }
        }
        return recruiteMenuList;
    }

    @Override
    public List<RecruiteMenu> selectMenuByUid(Long rid) {
        String sql="select recruite_menu.* from role_recruite_menu left join recruite_menu on recruite_menu.mid=role_recruite_menu.mid where role_recruite_menu.rid=?";
        return SqlUtil.select(RecruiteMenu.class, sql, rid);
    }
}
